#!/usr/bin/python
import os,sys

def printHelp():
	cmd = sys.argv[0]
	print 'Please use the following cmd:'
	print '    ' + cmd + ' -l file seeklinesize readlinesize'
	print '    ' + cmd + ' -b file seekbytesize readlinesize'
	print 'e.g.'
	print '    ' + cmd + ' -l xx.log 0 100' 
	print '    ' + cmd + ' -b xx.log 0 100' 

if len(sys.argv) != 5:
	printHelp()
else:
	flag = sys.argv[1]
	file = sys.argv[2]
	offset = long(sys.argv[3])
	readlinesize = long(sys.argv[4])
	
	if flag != "-l" and flag != "-b":
		printHelp()
		sys.exit()

	f = open(file, 'rb')
	if flag == "-l":
		for i in range(offset) :
			f.readline()			
	else:
		f.seek(offset)
	
	for i in range(readlinesize) :
		print f.readline()
	
	f.close()


